package com.pesking.core.sqlparser.processor;

import java.util.Arrays;
import java.util.List;

import com.pesking.core.globalid.GlobalIdManage;
import com.pesking.core.parameter.Parameter;
import com.pesking.core.sqlparser.parameter.SqlParameter;
import com.pesking.core.sqlparser.parameter.SqlParameterProcessor;
import com.pesking.core.util.LogUtils;
import com.pesking.core.util.StringUtils;

public class NUUIDSqlParameterHandler extends SqlParameterProcessor {
	@Override
	public String getTitle() {
		return "UUID参数";
	}

	@Override
	public String getDescription() {
		return null;
	}

	@Override
	public void handle(StringBuilder sbSQL, Parameter parameter, List<SqlParameter> processors,SqlParameter sqlParameter) {
		String uuid = "" + GlobalIdManage.generateGlobalID();
		String name = sqlParameter.getName();
		if (!StringUtils.isBlank(name)){
			parameter.setParameter(name, uuid);
		}
		LogUtils.debug( "NUUID参数:name[" + name + "]value[" + uuid + "]");
		sbSQL.append(uuid);
	}

	@Override
	public List<String> getSqlParameterType() {
		return Arrays.asList(new String []{"UUID"});
	}
	
}
